from fastapi import FastAPI
import uvicorn
from fastapi.middleware.cors import CORSMiddleware
from middleware.RequestInterceptor import RequestInterceptor
from plugins.mysql.database import engine
from models.userinfo import Base
from routers import auth
from routers.userinfo import userinfo
app = FastAPI()


app.include_router(auth.router, tags=["authentication"])
app.include_router(userinfo.router, tags=["get_userinfo"])

origins = [
    "*",
]
app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["GET", "POST", "PUT"],
    allow_headers=["*"]
)
app.add_middleware(RequestInterceptor)


# 创建所有表
Base.metadata.create_all(bind=engine)

@app.get("/")
async def root():
    return {"message": "lin Star bucket api"}


if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True, workers=1)

